home *** CD-ROM | disk | FTP | other *** search
/ PC Media 7 / PC MEDIA CD07.iso / share / uwin / cassette / cassette.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-28  |  4.6 KB  |  186 lines

  1. // Copyright (c) 1994, William Wagner
  2. // All Rights reserved.
  3. //
  4. // This source is a portion of a shareware program.  It may be distributed
  5. // only in its entirety.  The copyright statements must be included with any 
  6. // reproduction of this source.
  7. // 
  8.  
  9. // cassette.cpp : Defines the class behaviors for the application.
  10. //
  11.  
  12. #include "stdafx.h"
  13. #include "cassette.h"
  14.  
  15. #include "mainfrm.h"
  16. #include "cassedoc.h"
  17. #include "tapeview.h"
  18.  
  19. #ifdef _DEBUG
  20. #undef THIS_FILE
  21. static char BASED_CODE THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. // This is the help ID for about...
  25. const DWORD HID_APP_ABOUT=0x1E140;
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CCassetteApp
  29.  
  30. BEGIN_MESSAGE_MAP(CCassetteApp, CWinApp)
  31.     //{{AFX_MSG_MAP(CCassetteApp)
  32.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  33.     ON_COMMAND(ID_HELP_SEARCH, OnHelpSearch)
  34.     //}}AFX_MSG_MAP
  35.     // Standard file based document commands
  36.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  37.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  38.     // Standard print setup command
  39.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  40.     // Global help commands
  41.     ON_COMMAND(ID_HELP_INDEX, CWinApp::OnHelpIndex)
  42.     ON_COMMAND(ID_HELP_USING, CWinApp::OnHelpUsing)
  43.     ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  44.     ON_COMMAND(ID_CONTEXT_HELP, CWinApp::OnContextHelp)
  45.     ON_COMMAND(ID_DEFAULT_HELP, CWinApp::OnHelpIndex)
  46. END_MESSAGE_MAP()
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CCassetteApp construction
  50.  
  51. //Simple default constructor.
  52. CCassetteApp::CCassetteApp()
  53. {
  54. ASSERT_VALID (this);
  55. }
  56.  
  57. /////////////////////////////////////////////////////////////////////////////
  58. // The one and only CCassetteApp object
  59.  
  60. CCassetteApp NEAR theApp;
  61.  
  62. /////////////////////////////////////////////////////////////////////////////
  63. // CCassetteApp initialization
  64.  
  65. // Standard initialization
  66. // Register the application's document templates.  Document templates
  67. //  serve as the connection between documents, frame windows and views.
  68. // Here, use the tapeview view class.  The frame window will handle
  69. // the creation of the multiple views.
  70. // simple command line parsing
  71. BOOL CCassetteApp::InitInstance()
  72. {
  73. SetDialogBkColor();        // set dialog background color to gray
  74. LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  75.  
  76. AddDocTemplate(new CSingleDocTemplate(IDR_MAINFRAME,
  77.         RUNTIME_CLASS(CCassetteDoc),
  78.         RUNTIME_CLASS(CMainFrame),     // main SDI frame window
  79.         RUNTIME_CLASS(CTapeView)));
  80.  
  81. if (m_lpCmdLine[0] == '\0')
  82.     // create a new (empty) document
  83.     OnFileNew();
  84. else
  85.     // open an existing document
  86.     OpenDocumentFile(m_lpCmdLine);
  87.  
  88. return TRUE;
  89. }
  90.  
  91. /////////////////////////////////////////////////////////////////////////////
  92. // CAboutDlg dialog used for App About
  93.  
  94. class CAboutDlg : public CDialog
  95. {
  96. public:
  97.     //Default Constructor.
  98.     CAboutDlg();
  99.  
  100. // Dialog Data
  101.     //{{AFX_DATA(CAboutDlg)
  102.     enum { IDD = IDD_ABOUTBOX };
  103.     //}}AFX_DATA
  104.  
  105. // Implementation
  106. protected:
  107.     // Standard data exchange.
  108.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  109.     
  110.     // Map for the Register button.
  111.     //{{AFX_MSG(CAboutDlg)
  112.     afx_msg void OnClickedRegister();
  113.     //}}AFX_MSG
  114.     DECLARE_MESSAGE_MAP()
  115. };
  116.  
  117. //Constructor.  Construct the base class.
  118. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  119. {
  120. //{{AFX_DATA_INIT(CAboutDlg)
  121. //}}AFX_DATA_INIT
  122.     
  123. ASSERT_VALID (this);
  124. }
  125.  
  126. //The Data Exchanger.  There is 
  127. // nothing here.
  128. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  129. {
  130. ASSERT_VALID (this);
  131.  
  132. CDialog::DoDataExchange(pDX);
  133. //{{AFX_DATA_MAP(CAboutDlg)
  134. //}}AFX_DATA_MAP
  135.  
  136. ASSERT_VALID (this);
  137. }
  138.  
  139. //Register button clicked in the dialog.
  140. // Bring up the help screen associated with
  141. // registration.
  142. void CAboutDlg::OnClickedRegister()
  143. {
  144. ASSERT_VALID (this);
  145. ASSERT_VALID (::AfxGetApp ());
  146.  
  147. ::AfxGetApp ()->WinHelp (HID_APP_ABOUT, HELP_CONTEXT);   
  148.  
  149. ASSERT_VALID (this);
  150. }
  151.  
  152. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  153.     //{{AFX_MSG_MAP(CAboutDlg)
  154.     ON_BN_CLICKED(IDC_REGISTER, OnClickedRegister)
  155.     //}}AFX_MSG_MAP
  156. END_MESSAGE_MAP()
  157.  
  158. // App command to run the dialog
  159. // Just put the dialog on the screen.
  160. void CCassetteApp::OnAppAbout()
  161. {
  162. ASSERT_VALID (this);
  163.     
  164. CAboutDlg aboutDlg;
  165. ASSERT_VALID (&aboutDlg);
  166.  
  167. VERIFY (-1 != aboutDlg.DoModal());
  168.  
  169. ASSERT_VALID (this);
  170. }
  171.  
  172. /////////////////////////////////////////////////////////////////////////////
  173. // CCassetteApp commands
  174.  
  175. // Help Search command.  
  176. // Invoke WinHelp with a general search.
  177. void CCassetteApp::OnHelpSearch()
  178. {
  179. ASSERT_VALID (this);
  180.  
  181. char Unused = '\0';
  182. WinHelp (DWORD (&Unused), HELP_PARTIALKEY);   
  183.  
  184. ASSERT_VALID (this);
  185. }
  186.